From ae91495d46eab30824cf15e9cebceb9a88b3154d Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Sun, 3 Sep 2006 22:23:59 +0000 Subject: [PATCH] Add psmisc, closes #649 SVN-Revision: 4745 --- openwrt/package/Config.in | 1 + openwrt/package/Makefile | 1 + openwrt/package/psmisc/Config.in | 33 +++++++ openwrt/package/psmisc/Makefile | 98 +++++++++++++++++++++ openwrt/package/psmisc/ipkg/psmisc.control | 3 + openwrt/package/psmisc/ipkg/psmisc.postinst | 9 ++ openwrt/package/psmisc/ipkg/psmisc.postrm | 15 ++++ openwrt/package/psmisc/ipkg/psmisc.preinst | 24 +++++ openwrt/package/psmisc/ipkg/psmisc.prerm | 9 ++ 9 files changed, 193 insertions(+) create mode 100644 openwrt/package/psmisc/Config.in create mode 100644 openwrt/package/psmisc/Makefile create mode 100644 openwrt/package/psmisc/ipkg/psmisc.control create mode 100644 openwrt/package/psmisc/ipkg/psmisc.postinst create mode 100644 openwrt/package/psmisc/ipkg/psmisc.postrm create mode 100644 openwrt/package/psmisc/ipkg/psmisc.preinst create mode 100644 openwrt/package/psmisc/ipkg/psmisc.prerm diff --git a/openwrt/package/Config.in b/openwrt/package/Config.in index bcc6f17648..dc576182a4 100644 --- a/openwrt/package/Config.in +++ b/openwrt/package/Config.in @@ -18,6 +18,7 @@ source "package/microperl/Config.in" source "package/monit/Config.in" source "package/osiris/Config.in" source "package/procps/Config.in" +source "package/psmisc/Config.in" menu "sablevm - a Java Virtual Machine (JVM) implementation" source "package/sablevm/Config.in" source "package/sablevm-classpath/Config.in" diff --git a/openwrt/package/Makefile b/openwrt/package/Makefile index 79a45cffd3..0b9c14e00a 100644 --- a/openwrt/package/Makefile +++ b/openwrt/package/Makefile @@ -92,6 +92,7 @@ package-$(BR2_PACKAGE_PPP) += ppp package-$(BR2_PACKAGE_PPTP) += pptp package-$(BR2_PACKAGE_PPTPD) += pptpd package-$(BR2_PACKAGE_PROCPS) += procps +package-$(BR2_PACKAGE_PSMISC) += psmisc package-$(BR2_PACKAGE_QUAGGA) += quagga package-$(BR2_PACKAGE_RADVD) += radvd package-$(BR2_COMPILE_RADIUSCLIENT_NG) += radiusclient-ng diff --git a/openwrt/package/psmisc/Config.in b/openwrt/package/psmisc/Config.in new file mode 100644 index 0000000000..50d13c0576 --- /dev/null +++ b/openwrt/package/psmisc/Config.in @@ -0,0 +1,33 @@ +menu "Misc /proc utilities" + +config BR2_PACKAGE_PSMISC + prompt "Misc /proc utilities" + tristate + default m if CONFIG_DEVEL + help + PSmisc package is a set of additional small useful utilities that use + the proc filesystem: fuser, killall, pstree, and pidof + + http://psmisc.sourceforge.net/ + +config BR2_PACKAGE_PSMISC_FUSER + prompt "fuser - identify processes using files or sockets" + bool + default y if CONFIG_DEVEL + depends BR2_PACKAGE_PSMISC + +config BR2_PACKAGE_PSMISC_KILLALL + prompt "killall - kill process by name, pidof - find PIDs by name" + bool + default y if CONFIG_DEVEL + depends BR2_PACKAGE_PSMISC + +config BR2_PACKAGE_PSMISC_PSTREE + prompt "pstree (requires libncurses) - display a tree of processes" + bool + default y if CONFIG_DEVEL + depends BR2_PACKAGE_PSMISC + select BR2_PACKAGE_LIBNCURSES + depends BR2_PACKAGE_PSMISC + +endmenu diff --git a/openwrt/package/psmisc/Makefile b/openwrt/package/psmisc/Makefile new file mode 100644 index 0000000000..11a8dc48d4 --- /dev/null +++ b/openwrt/package/psmisc/Makefile @@ -0,0 +1,98 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=psmisc +PKG_VERSION:=22.2 +PKG_RELEASE:=1 +PKG_MD5SUM:=77737c817a40ef2c160a7194b5b64337 + +PKG_SOURCE_URL:=@SF/psmisc +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_CAT:=zcat + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) +PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install + +include $(TOPDIR)/package/rules.mk + +$(eval $(call PKG_template,PSMISC,$(PKG_NAME),$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH))) + +$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared + (cd $(PKG_BUILD_DIR); \ + $(TARGET_CONFIGURE_OPTS) \ + CFLAGS="$(TARGET_CFLAGS)" \ + CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \ + LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \ + ./configure \ + --target=$(GNU_TARGET_NAME) \ + --host=$(GNU_TARGET_NAME) \ + --build=$(GNU_HOST_NAME) \ + --prefix=$(PKG_INSTALL_DIR) \ + --without-libiconv-prefix \ + --without-libintl-prefix \ + --disable-nls \ + --disable-ipv6 \ + --disable-largefile\ + ); + + touch $@ + +APPS:= + +ifneq ($(BR2_PACKAGE_PSMISC_FUSER),) +APPS += /sbin/fuser +endif +ifneq ($(BR2_PACKAGE_PSMISC_KILLALL),) +APPS += /usr/bin/killall /bin/pidof +endif +ifneq ($(BR2_PACKAGE_PSMISC_PSTREE),) +APPS += /usr/bin/pstree +endif + +$(PKG_BUILD_DIR)/.built: + rm -rf $(PKG_INSTALL_DIR) + mkdir -p $(PKG_INSTALL_DIR)/usr/bin + mkdir -p $(PKG_INSTALL_DIR)/sbin + mkdir -p $(PKG_INSTALL_DIR)/bin + #Note here that we pass cross-compiler as default compiler to use + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC=$(TARGET_CC) \ + CPPFLAGS="-I$(STAGING_DIR)/usr/include" \ + LD="$(TARGET_CC)" \ + LDFLAGS="-L$(STAGING_DIR)/usr/lib" \ + $(TARGET_CONFIGURE_OPTS) \ + prefix="$(PKG_INSTALL_DIR)" + + if [ -n "$(BR2_PACKAGE_PSMISC_KILLALL)" ];then $(CP) $(PKG_BUILD_DIR)/src/killall $(PKG_INSTALL_DIR)/usr/bin;fi + if [ -n "$(BR2_PACKAGE_PSMISC_FUSER)" ];then $(CP) $(PKG_BUILD_DIR)/src/fuser $(PKG_INSTALL_DIR)/sbin;fi + if [ -n "$(BR2_PACKAGE_PSMISC_PSTREE)" ];then $(CP) $(PKG_BUILD_DIR)/src/pstree $(PKG_INSTALL_DIR)/usr/bin;fi + + touch $@ + +$(IPKG_PSMISC): + install -d -m0755 $(IDIR_PSMISC)/usr/bin + install -d -m0755 $(IDIR_PSMISC)/sbin + install -d -m0755 $(IDIR_PSMISC)/bin + + if [ -n "$(BR2_PACKAGE_PSMISC_KILLALL)" ];then $(CP) $(PKG_INSTALL_DIR)/usr/bin/killall $(IDIR_PSMISC)/usr/bin;fi + if [ -n "$(BR2_PACKAGE_PSMISC_FUSER)" ];then $(CP) $(PKG_INSTALL_DIR)/sbin/fuser $(IDIR_PSMISC)/sbin;fi + if [ -n "$(BR2_PACKAGE_PSMISC_PSTREE)" ];then $(CP) $(PKG_INSTALL_DIR)/usr/bin/pstree $(IDIR_PSMISC)/usr/bin;fi + + $(RSTRIP) $(IDIR_PSMISC) + + # Insert BUILT variable into preinst script + grep -v -e ^BUILT -e /bin/sh $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst > $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst.tmp + rm $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst + echo -e "#!/bin/sh\nBUILT='$(APPS)'\n" > $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst + cat $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst.tmp >> $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst + rm $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst.tmp + + if [ -n "$(BR2_PACKAGE_PSMISC_PSTREE)" ] || \ + [ -n "$(BR2_PACKAGE_PSMISC_PSTREE)" ]; then\ + echo "Depends: libncurses" >> $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/control; fi + echo "Description: Extra /proc utils: $(notdir $(APPS))" >> \$(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/control + + $(IPKG_BUILD) $(IDIR_PSMISC) $(PACKAGE_DIR) + +mostlyclean: + make -C $(PKG_BUILD_DIR) clean + rm $(PKG_BUILD_DIR)/.built diff --git a/openwrt/package/psmisc/ipkg/psmisc.control b/openwrt/package/psmisc/ipkg/psmisc.control new file mode 100644 index 0000000000..08847677a6 --- /dev/null +++ b/openwrt/package/psmisc/ipkg/psmisc.control @@ -0,0 +1,3 @@ +Package: psmisc +Priority: optional +Section: admin diff --git a/openwrt/package/psmisc/ipkg/psmisc.postinst b/openwrt/package/psmisc/ipkg/psmisc.postinst new file mode 100644 index 0000000000..4e6f6540c9 --- /dev/null +++ b/openwrt/package/psmisc/ipkg/psmisc.postinst @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ -f /usr/bin/killall ] +then + echo "Hard linking pidof to killall" + ln /usr/bin/killall /bin/pidof +fi + +exit 0 diff --git a/openwrt/package/psmisc/ipkg/psmisc.postrm b/openwrt/package/psmisc/ipkg/psmisc.postrm new file mode 100644 index 0000000000..9dcab829f3 --- /dev/null +++ b/openwrt/package/psmisc/ipkg/psmisc.postrm @@ -0,0 +1,15 @@ +#!/bin/sh + +BINS="/sbin/fuser /usr/bin/killall /usr/bin/pstree /bin/pidof" +echo "Recreating original BusyBox links: " + +for bin in $BINS +do + if busybox 2>&1 | grep ${bin##/*/} >/dev/null + then + echo "$bin " + ln -sf /bin/busybox $bin + fi +done + +exit 0 diff --git a/openwrt/package/psmisc/ipkg/psmisc.preinst b/openwrt/package/psmisc/ipkg/psmisc.preinst new file mode 100644 index 0000000000..1a5518d4fb --- /dev/null +++ b/openwrt/package/psmisc/ipkg/psmisc.preinst @@ -0,0 +1,24 @@ +#!/bin/sh + +echo "Removing symbolic links to BusyBox: " +for bin in $BUILT +do + if [ -h $bin ] + then + echo "$bin " + rm -f $bin + elif [ -e $bin ] + then + echo -e "$bin exists but is not a symbolic link.\nRe-creating BusyBox links and aborting..." + for bin in $BUILT + do + if busybox 2>&1 | grep ${bin##/*/} >/dev/null && [ ! -e $bin ] + then + ln -s /bin/busybox $bin + fi + done + exit 1 + fi +done + +exit 0 diff --git a/openwrt/package/psmisc/ipkg/psmisc.prerm b/openwrt/package/psmisc/ipkg/psmisc.prerm new file mode 100644 index 0000000000..c229d222c5 --- /dev/null +++ b/openwrt/package/psmisc/ipkg/psmisc.prerm @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ -f /sbin/pidof ] +then + echo "Removing hard link from pidof to killall" + rm -f /sbin/pidof +fi + +exit 0 -- 2.30.2